<h1>DefineMorphShape</h1>

<p>DefineMorphShape defines a shape that will morph from one form into another. Only the start and end shapes are defined the Flash Player will perform the interpolation that transforms the shape at each staging in the morphing process.</p>

<p>Morphing can be applied to any shape, however there are a few restrictions:</p>

<div style="padding-left:20px; margin-bottom:10px;">
<ul>
<li>The start and end shapes must have the same number of edges (Lines and Curves).</li>
<li>The fill style (Solid, Bitmap or Gradient) must be the same in the start and end shape.</li>
<li>If a bitmap fill style is used then the same image must be used in the start and end shapes.</li>
<li>If a gradient fill style is used then the gradient must contain the same number of points in the start and end shape.</li>
<li>The start and end shape must contain the same set of ShapeStyles.</li>
</ul>
</div>

<p>To perform the morphing of a shape the shape is placed in the display list 
using a PlaceObject2 command. The ratio attribute in PlaceObject2 defines the 
progress of the morphing process. The ratio ranges between 0.0 and 1.0 where 0 
represents the start of the morphing process and 1.0, the end.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">10</td>
<td>Identifies the DefineMorphShape instruction when it is encoded. It is encoded 
with the length field as a 16-bit integer (Little-endian byte order).</td>
</tr>

<tr>
<td nowrap valign="top">length</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">6</td>
<td>The length in bytes of the body of the instruction when it is encoded. If the length is greater 
than 62 then this field is set to 0x3F and the length is encoded using the 
extendedLength field. Encoded with the type field as a 16-bit integer.</td>
</tr>

<tr>
<td nowrap valign="top">extendedLength</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>Optional. Contains the length in bytes of the encoded instruction if it is
greater than 62 bytes. If the length is 62 bytes or less then this field is 
omitted.</td>
</tr>

<tr>
<td nowrap valign="top">identifier</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The unique identifier for this shape. This is used when adding or removing 
the shape from the display list or when the shape is used as part of another 
object such as a button.</td>
</tr>

<tr>
<td nowrap valign="top">startBounds</td>
<td nowrap valign="top">Bounds</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>The bounding rectangle defining the area in which the shape is drawn at the 
start of the morph process.</td>
</tr>

<tr>
<td nowrap valign="top">endBounds</td>
<td nowrap valign="top">Bounds</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>The bounding rectangle defining the area in which the shape is drawn at the
 end of the morph process.</td>
</tr>

<tr>
<td nowrap valign="top">offset</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>The offset in bytes to the start of the end shape definition.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyleCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of fill styles following. For shapes that contain more than 
254 fill styles this field is set to 0xFF (255) and the following 16-bit field
is used to specify the number of fill styles.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyleCountExtended</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Optional. Allows shapes to be define with more than 254 fill styles. This 
field is rarely used in practice.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyles</td>
<td nowrap valign="top">FillStyle[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of fill styles used to fill the area enclosed by the shape.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyleCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of line styles following. For shapes that contain more than 
254 line styles this field is set to 0xFF (255) and the following 16-bit field
is used to specify the number of line styles.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyleCountExtended</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Optional. Allows shapes to be define with more than 254 line styles. This 
field is rarely, if ever, used in practice.</td>
</tr>

<tr><td nowrap valign="top">startShape</td>
<td nowrap valign="top">Shape</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>The Shape that describe the shape at the start of the morphing process.</td>
</tr>

<tr>
<td nowrap valign="top">endShape</td>
<td nowrap valign="top">Shape</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>The shape at the end of the morphing process containing the Lines and Curves
 that define the edges of the shape. ShapeStyles may only be included if they are 
 used to move the current point and may <b>not</b> change the style being used 
 to draw the shape.</td>
</tr>
</table>

<p>The edges may change their type when a shape is morphed. Straight edges can become curves and vice versa.</p>

<h2>History</h2>

<p>DefineMorphShape represents the DefineMorphShape tag from the Macromedia Flash 
(SWF) File Format Specification. It was introduced in Flash 3.</p>
